package cn.jjxx.modules.sso.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.jjxx.core.model.AjaxJson;
import cn.jjxx.modules.sso.service.ISSOClientService;

@Controller
@RequestMapping("${admin.url.prefix}/sso/client")
public class SSOClientController {
	
	@Autowired
	private ISSOClientService ssoClientService;
	
	@RequestMapping(value = "/login",method = RequestMethod.GET)
	@ResponseBody
	public String login(HttpServletRequest request,HttpServletResponse response,
			@RequestParam("jsonpCallback") String jsonpCallback, String encryptParams){
		return ssoClientService.login(jsonpCallback, encryptParams);
	}
	
	@RequestMapping(value = "/login",method = RequestMethod.POST)
	@ResponseBody
	public AjaxJson login(HttpServletRequest request,HttpServletResponse response,String encryptParams){
		return ssoClientService.login(encryptParams);
	}
	
	@RequestMapping(value = "/checkToken",method =  RequestMethod.POST )
	@ResponseBody
	public AjaxJson checkToken(HttpServletRequest request,HttpServletResponse response){
		return ssoClientService.checkToken();
	}
}
